local sk__lingbo = fk.CreateSkill {

  name = "sk__lingbo",

  tags = {  },

}



sk__lingbo:addEffect(fk.EventPhaseStart, {
  name = "sk__lingbo",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__lingbo.name) and target.phase == Player.Start and player.chained
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.chained then
      player:setChainState(false)
    end
    if player.dead then return end
    local targets = table.filter(player.room.alive_players, function(p)
      return #p:getCardIds("ej") > 0
    end)
    if #targets == 0 then return end
    local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#sk__lingbo-choose", sk__lingbo.name, false)
    to = room:getPlayerById(to[1])
    local card = room:askForCardChosen(player, to, "ej", sk__lingbo.name, "#sk__lingbo-card::"..to.id)
    room:moveCards({
      ids = {card},
      from = to,
      toArea = Card.DrawPile,
      moveReason = fk.ReasonPut,
      skillName = sk__lingbo.name,
      proposer = player,
      drawPilePosition = 1,
    })
  end,
})

return sk__lingbo